#ifndef IMAGE_FILTER_WORKER_H
#define IMAGE_FILTER_WORKER_H

#include <QtCore/QObject>
#include <QtGui/QImage>
#include <QtCore/QThread>
#include <memory>
#include <mutex>

#include "lockfree_queue.h"
#include "face_beauty_interface.h"

class ImageHandler
{
public:
    virtual ~ImageHandler() {};
    virtual int ProccessFrame(QImage* frame) = 0;
};

class ImageFilterWorker: public QThread, public ImageHandler
{
    Q_OBJECT
public:
    ImageFilterWorker();
    virtual ~ImageFilterWorker();

public slots:
    virtual int ProccessFrame(QImage* frame) override;

protected:
    virtual void run() override;

public:
    int InitHandler(ImageHandler* handler);
    int InitModule(int feature, std::size_t width, std::size_t height, facebeauty::FACE_BEAUTY_COLOR_SPACE color);
    int SetFeatureQuality(int feature, int quality);
    int Reset();

private:
    std::shared_ptr<facebeauty::FaceBeautyInterface> filter_;

    dpl::LockfreeQueue<QImage*> images_;
    ImageHandler* output_handler_;
};

#endif // IMAGE_FILTER_WORKER_H
